<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="x-ua-compatible" content="ie=7" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>超管授权</title>
<link href="/webvote/pages/style/main.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="/webvote/pages/js/role.js"></script>
<script type="text/javascript">
	    	//提交表单
	    	function impowersubmit(){
	    		document.getElementById("temprid").value=document.getElementById("roleinfo.rid").selectedIndex;
	    		document.menuForm.submit();
	    	}
	    	
	    	function updatemenu(){
				//得到所有的菜单
		    	document.menuForm.action = "/webvote/menu.do?action=updateMenuByRid";
	    		impowersubmit();
	    	}
	    	function xuan(){
	    		document.getElementById("roleinfo.rid").selectedIndex = document.getElementById("temprid").value;
	    	}
    	</script>
</head>

<body onload="xuan()" style=" width:100%; background:url(/webvote/pages/images/index-1_15.gif) repeat-x #f3f3f3;">
<div class="c-top f14"><img src="/webvote/pages/images/download2 r.gif" /><p>您当前所在的位置：<span>权限管理</span>>><span>超管授权</span></p></div>
<div class="shouquan">
          <form name="menuForm" action="/webvote/menu.do?action=queryMenuBySRid" method="post">     
          <p class="tille">角色名称：
          					
          					<select name="roleinfo.rid" class="xuanze" onchange="impowersubmit()">
                                   <c:forEach var="all" items="${allroleinfo}">
									<option value="${all.rid }">${all.rname }</option>
								   </c:forEach>
						    </select>
						    <input type="hidden" name="temprid" value="${menuForm.temprid }" />
       <c:forEach var="pmenu" items="${allonemenuInfo}"> 
           <!-- 判断是否勾选了一级菜单 -->
           <c:set var="flag" value="0" />
							<c:forEach var="rolmenu" items="${onemenuInfo}">
								<c:if test="${pmenu.mid eq rolmenu.mid}">
									<c:set var="flag" value="1" />		
		 						</c:if>
			</c:forEach>                       
          <dl>
            <dt>
              <c:if test="${flag == 1}">
                <input type="checkbox" checked="checked" id="${pmenu.mid}" value="${pmenu.mid}" name="rolmenu" onclick="selectonemenu(this)" />
              ${pmenu.mname }
              </c:if>
              <c:if test="${flag == 0}">
                <input type="checkbox"  id="${pmenu.mid}" value="${pmenu.mid}" name="rolmenu" onclick="selectonemenu(this)" />
              ${pmenu.mname }
              </c:if>
             </dt>
                <!-- 判断是否勾选二级菜单 -->
                <c:set var="juageChild" value="0" />
                <c:forEach var="cmenu" items="${pmenu.childMenuList}">
								<c:forEach var="rolchildmenu" items="${onemenuInfo}">
									<c:forEach var="rcmn" items="${rolchildmenu.childMenuList}">
										<c:if test="${cmenu.mid == rcmn.mid}">
											<c:set var="juageChild" value="1" />
          										<dd><input type="checkbox" checked="checked" name="rolmenu" id="${pmenu.mid }_${cmenu.mid }" value="${cmenu.mid }" onclick="selectedchild(this)" />
          										${cmenu.mname }</dd>
          								</c:if>
          							</c:forEach>
								</c:forEach>
								<c:if test="${juageChild == 0}">
									<dd><input type="checkbox" name="rolmenu" id="${pmenu.mid }_${cmenu.mid }" value="${cmenu.mid }" onclick="selectedchild(this)" />
          										${cmenu.mname }</dd>
								</c:if>
			   <c:set var="juageChild" value="0" />
			   </c:forEach>
          </dl>
       </c:forEach>
          
          <div class="anniu"><input name="" type="button" value="保&nbsp;&nbsp;&nbsp;存" onclick="updatemenu()" /><input name="" type="button" value="取&nbsp;&nbsp;&nbsp;消" onclick="javascript:history.go(-1)"/>
    </div></form>
  </div>
</body>
</html>

